﻿using System;
using UnityEngine;
using UnityEngine.Networking;

// Token: 0x0200030A RID: 778
public class AnimatedMicroNPC : MicroNPC
{
	// Token: 0x060013AF RID: 5039 RVA: 0x00083AC4 File Offset: 0x00081CC4
	protected override void Awake()
	{
		base.Awake();
		if (this.anim != null && this.lookController == null)
		{
			this.diffAngle = Vector3.Angle(base.transform.forward, this.anim.GetBoneTransform(HumanBodyBones.Head).forward);
			if (Mathf.Abs(this.diffAngle) > 5f)
			{
				this.lookController = base.gameObject.AddComponent<ComplexMicroLookAtController>();
			}
			else
			{
				this.lookController = base.gameObject.AddComponent<MicroLookAtController>();
			}
		}
	}

	// Token: 0x060013B0 RID: 5040 RVA: 0x00083B60 File Offset: 0x00081D60
	public void LookAt(EntityBase target)
	{
		if (this.anim != null && this.lookController != null && !base.isCrushed)
		{
			if (!this.lookController.enabled)
			{
				this.lookController.enabled = true;
			}
			this.lookController.LookAt(target);
		}
	}

	// Token: 0x060013B1 RID: 5041 RVA: 0x00083BC2 File Offset: 0x00081DC2
	protected override void OnDestroy()
	{
		this.ai.DisableAI();
		UnityEngine.Object.Destroy(this.lookController);
		base.OnDestroy();
	}

	// Token: 0x060013B2 RID: 5042 RVA: 0x00002973 File Offset: 0x00000B73
	private void UNetVersion()
	{
	}

	// Token: 0x060013B3 RID: 5043 RVA: 0x00083BE0 File Offset: 0x00081DE0
	public override bool OnSerialize(NetworkWriter writer, bool forceAll)
	{
		bool flag = base.OnSerialize(writer, forceAll);
		bool flag2;
		return flag2 || flag;
	}

	// Token: 0x060013B4 RID: 5044 RVA: 0x00083BF9 File Offset: 0x00081DF9
	public override void OnDeserialize(NetworkReader reader, bool initialState)
	{
		base.OnDeserialize(reader, initialState);
	}

	// Token: 0x040016FE RID: 5886
	public MicroLookAtController lookController;

	// Token: 0x040016FF RID: 5887
	private float diffAngle;
}
